#include"multree.h"
_dsl_multree_t _dsl_multree_alloc(const _dsl_element_t e)
{
	_dsl_multree_t t;
	t=(_dsl_multree_t)_gdsl_bintree_alloc((gdsl_element_t)e,NULL,NULL);
	return t;
}
void _dsl_multree_set_child(_dsl_multree_t t,const _dsl_multree_t child)
{
	_gdsl_bintree_t temp;
	if((temp=_gdsl_bintree_get_left((_gdsl_bintree_t)t))==NULL){
		_gdsl_bintree_set_left((_gdsl_bintree_t)t,(_gdsl_bintree_t)child);
	}
	else{
		while(_gdsl_bintree_get_right(temp))
			temp=_gdsl_bintree_get_right(temp);
		_gdsl_bintree_set_right(temp,(_gdsl_bintree_t)child);
	}	
	_gdsl_bintree_set_parent((_gdsl_bintree_t)child,(_gdsl_bintree_t)t);
}
void _dsl_multree_set_parent(_dsl_multree_t t,_dsl_multree_t p)
{
	_gdsl_bintree_set_parent((_gdsl_bintree_t)t,(_gdsl_bintree_t)p);
}
void _dsl_multree_free(_dsl_multree_t t,const dsl_free_func_t free_f)
{
	_gdsl_bintree_free((_gdsl_bintree_t) t,(gdsl_free_func_t) free_f);
}
_dsl_multree_t _dsl_multree_get_child(const _dsl_multree_t t,int i)
{
	_gdsl_bintree_t temp;
	int j;
	temp=_gdsl_bintree_get_left((_gdsl_bintree_t)t);
	if(i==0)
		return (_dsl_multree_t)temp;
	else
		for(j=0;j<i;j++)
			temp=_gdsl_bintree_get_right(temp);
	return (_dsl_multree_t)temp;
}
_dsl_element_t _dsl_multree_get_content(const _dsl_multree_t t)
{
	return (_dsl_element_t)_gdsl_bintree_get_content((_gdsl_bintree_t)t);
}
